#ifndef DATA_ROTOR_H
#define DATA_ROTOR_H

#include <string>
#include "Common/Algebra/Vec2.h"
#include "Common/Collections/Vector.h"

#include "Data/Objects/RotorDef.h"
#include "Data/Objects/Rule.h"

namespace data {

	class Rotor {
	public:
		Rotor(
			std::string id,
			std::string detailAId,
			std::string detailBId,
			const cmn::Vec2& position,
			std::string definitionFileName ) :
			m_id( id ),
			m_detailAId( detailAId ),
			m_detailBId( detailBId ),
			m_position( position ),
			m_definitionFileName( definitionFileName )
		{
			m_rules = new cmn::Vector<Rule>();
		}

		Rotor( const Rotor& rotor ) :
			m_id( rotor.m_id ),
			m_detailAId( rotor.m_detailAId ),
			m_detailBId( rotor.m_detailBId ),
			m_position( rotor.m_position ),
			m_definitionFileName( rotor.m_definitionFileName )
		{
			m_rules = new cmn::Vector<Rule> ( rotor.m_rules );
		}

		~Rotor() {
			delete m_rules;
		}

		inline const std::string GetId() const { return m_id; }
		inline void SetId( std::string id ) { m_id = id; }

		inline const std::string GetDetailAId() const { return m_detailAId; }
		inline void SetDetailAId( std::string detailAId ) { m_detailAId = detailAId; }

		inline const std::string GetDetailBId() const { return m_detailBId; }
		inline void SetDetailBId( std::string detailBId ) { m_detailBId = detailBId; }

		inline const cmn::Vec2 GetPosition() const { return m_position; }
		inline void SetPosition( const cmn::Vec2& position ) { m_position = position; }

		const std::string GetDefinitionFileName() const { return m_definitionFileName; }
		inline void SetDefinitionFileName( std::string definitionFileName ) { m_definitionFileName = definitionFileName; }

		inline void AddRule( const Rule& rule ) { m_rules->Add( rule ); }
		inline void RemoveRule( const Rule& rule ) { m_rules->Remove( rule ); }
		inline const cmn::IIterable<Rule>* GetRules() const { return m_rules; }

	private:
		std::string m_id;
		std::string m_detailAId;
		std::string m_detailBId;
		cmn::Vec2 m_position;
		std::string m_definitionFileName;
		cmn::Vector<Rule>* m_rules;
	};

	inline bool operator == ( const Rotor& a, const Rotor& b ) {
		if( a.GetId() != b.GetId() ) return false;
		if( a.GetDetailAId() != b.GetDetailAId() ) return false;
		if( a.GetDetailBId() != b.GetDetailBId() ) return false;
		if( a.GetPosition() != b.GetPosition() ) return false;
		if( a.GetDefinitionFileName() != b.GetDefinitionFileName() ) return false;

		if( !IterablesAreEqual( a.GetRules(), b.GetRules() ) ) return false;
		return true;
	}

	inline bool operator != ( const Rotor& a, const Rotor& b ) {
		return !( a == b );
	}
}
#endif
